In [1]:
# common
import sys
import os
import os.path as op

# basic
import numpy as np
import pandas as pd
import xarray as xr
from time import time
import warnings
warnings.simplefilter('ignore')

# custom
from lib import calval

# functions
from lib import functions
In [2]:
# initial time to see the duration of the notebook
t0 = time()
In [3]:
# data 
p_data = op.join(os.getcwd(), 'data')

buoy       =  pd.read_pickle(op.join(p_data, 'buoy', 'Bilbao-Vizcaya Ext.pkl'))
csiro      =  pd.read_pickle(op.join(p_data, 'hindcast', 'csiro_dataframe.pkl'))
satellite  =  xr.open_dataset(op.join(p_data, 'satellite', 'satellite_dataset.nc'))

print('---------------------------------------------------')
print('Time wasted reading the data: ' + str(round(time()-t0, 2)) + ' s')
print('---------------------------------------------------')
---------------------------------------------------
Time wasted reading the data: 0.35 s
---------------------------------------------------
In [4]:
t1 = time()
In [5]:
# creation of the main object

#######################################################
###   VALUES WILL HAVE TO BE INSERTED SO BE READY   ###
###   Satellite box :    South = 43.8               ###
###                      North = 44.2               ###
###                      West  = 356.2              ###
###                      East  = 356.6              ###
###   Time calibration:  False                      ###
###   Threshold :        0.015                      ###
#######################################################

# the threshold allows us to delete not relevant information

calval_case = calval.CalVal(buoy, csiro, satellite)

print('---------------------------------------------------')
print('Time wasted initializing the constructor: ' + str(round((time()-t1)/60, 2)) + ' m')
print('---------------------------------------------------')
--------------------------------------------------------
SAT CALIBRATION will be performed
-------------------------------------------------------- 
 
Satellite box values: 
South latitude: 43.8
North latitude: 44.2
West latitude: 356.2
East latitude: 356.6
 
 
Selecting the satellite data choosed... 
 
Satellite length: 10390 
 
Hindcast information able to calibrate: 360839 
 
Choose the way to calibrate the data: 
True: hindcast for each satellite 
False: satellite for each hindcast 
----- Select ----- : False
 
 
Performing the time calibration... 
 
Length of data to calibrate: 6415 
 
 
 
Constructing matrices and calibrating... 
 
Value to set the umbral for not enough data to calibrate, 
this value can be from 0.01 to 0.03: 
----- Threshold ----- : 0.015
 
 
 
 
Params used for the SATELLITE calibration are: 
 
[1.23093778 1.14244441 0.97757068 1.10793525 1.0838803  1.
 1.03734986 1.         1.52190871 1.         1.         1.
 0.97892031 1.03219979 1.03090611 1.18071745 1.03394469 1.01435525
 1.         1.         1.         1.         1.         1.
 1.         1.         1.         1.         1.12602901 1.08305587
 1.11051724 1.17410925]
 
 
Plotting just the data used to calibrate... 
 
Saving corrected results... 
 
 
  
 
--------------------------------------------------------
BUOY CALIBRATION will be performed
-------------------------------------------------------- 
 
 
 
Constructing matrices and calibrating... 
 
Value to set the umbral for not enough data to calibrate, 
this value can be from 0.01 to 0.03: 
----- Threshold ----- : 0.015
 
 
 
 
Params used for the BUOY calibration are: 
 
[1.02137022 0.96863021 0.86212164 0.8258302  1.         1.
 0.6200418  1.         1.         1.         1.         1.
 0.89601481 1.00653646 1.05089847 1.05307368 1.05729298 1.09789492
 1.         1.         1.         1.         1.         1.
 1.         1.         1.         1.         0.95365576 1.02998954
 1.1126027  1.17649791]
 
 
Plotting just the data used to calibrate... 
 
Saving corrected results... 
 
 
  
 
---------------------------------------------------
Time wasted initializing the constructor: 26.15 m
---------------------------------------------------
In [6]:
t1 = time()
In [7]:
# calval_case.hindcast_sat_corr.to_pickle(op.join(p_data, 'hindcast', 'csiro_dataframe_sat_corr.pkl'))
# calval_case.hindcast_buoy_corr.to_pickle(op.join(p_data, 'hindcast', 'csiro_dataframe_buoy_corr.pkl'))
In [8]:
# comparisons

#######################################################
###   VALUES WILL HAVE TO BE INSERTED SO BE READY   ###
###   Number of years :    3                        ###
###   Years :              2006 2007 2008           ###
#######################################################

calval_case.buoy_comparison('raw')
--------------------------------------------------------
RAW comparison will be performed
-------------------------------------------------------- 
 
Number of years: 3
Years separated by one space: 2006 2007 2008
 
 
Comparing data... 
 
In [9]:
calval_case.buoy_comparison('sat_corr')
--------------------------------------------------------
SAT_CORR comparison will be performed
-------------------------------------------------------- 
 
Number of years: 3
Years separated by one space: 2006 2007 2008
 
 
Comparing data... 
 
In [10]:
calval_case.buoy_comparison('buoy_corr')
--------------------------------------------------------
BUOY_CORR comparison will be performed
-------------------------------------------------------- 
 
Number of years: 3
Years separated by one space: 2006 2007 2008
 
 
Comparing data... 
 
In [11]:
print('---------------------------------------------------')
print('Time wasted comparing: ' + str(round((time()-t1)/60, 2)) + ' m')
print('---------------------------------------------------')
---------------------------------------------------
Time wasted comparing: 14.66 m
---------------------------------------------------
In [12]:
t1 = time()
In [13]:
# validations

calval_case.buoy_validation('raw')
--------------------------------------------------------
RAW VALIDATION will be performed
-------------------------------------------------------- 
 
Validating and plotting validated data... 
 
Length of data to validate: 59119 
 
In [14]:
calval_case.buoy_validation('sat_corr')
--------------------------------------------------------
SAT_CORR VALIDATION will be performed
-------------------------------------------------------- 
 
Validating and plotting validated data... 
 
Length of data to validate: 59119 
 
In [15]:
calval_case.buoy_validation('buoy_corr')
--------------------------------------------------------
BUOY_CORR VALIDATION will be performed
-------------------------------------------------------- 
 
Validating and plotting validated data... 
 
Length of data to validate: 59119 
 
In [16]:
print('---------------------------------------------------')
print('Time wasted validating: ' + str(round((time()-t1)/60, 2)) + ' m')
print('---------------------------------------------------')
---------------------------------------------------
Time wasted validating: 11.34 m
---------------------------------------------------
In [17]:
print('---------------------------------------------------')
print('TOTAL time of the script: ' + str(round((time()-t0)/60, 2)) + ' m')
print('---------------------------------------------------')
---------------------------------------------------
TOTAL time of the script: 52.28 m
---------------------------------------------------